var pageParam = {};

function saveGoNextPage() {
	elderView.data.sex = (elderView.data.sex==''? 0: parseInt(elderView.data.sex));
	elderView.data.personType = (elderView.data.personType==''? 0: parseInt(elderView.data.personType));
	elderView.data.beHospitalStatus = (elderView.data.beHospitalStatus==''? 0: parseInt(elderView.data.beHospitalStatus));
	elderView.data.elderType = 2;
	elderFamilyMemberView.data.sex = (elderFamilyMemberView.data.sex==''? 0: parseInt(elderFamilyMemberView.data.sex));
	elderMemContactsView.data.sex = (elderMemContactsView.data.sex==''? 0: parseInt(elderMemContactsView.data.sex));
	
	elderView.data.birthday = elderView.data.year + '-' + elderView.data.month + '-' + elderView.data.day;
	elderFamilyMemberView.data.birthday = elderFamilyMemberView.data.year + '-' + elderFamilyMemberView.data.month + '-' + elderFamilyMemberView.data.day;
	elderMemContactsView.data.birthday = elderMemContactsView.data.year + '-' + elderMemContactsView.data.month + '-' + elderMemContactsView.data.day;

	save_basic(path+'/elder/saveElderBaseInfo',
		{elder:elderView.data, elderFamilyMember:elderFamilyMemberView.data, elderMemContacts:elderMemContactsView.data},
		function(response) {
			alert('院外长者资料保存成功！将进入下一页。');
			goNextPage(response.data[0].elderId);
	});
}

function goNextPage(elderId) {
	pageParam.elderId = elderId;
	pageParam.elderName = elderView.data.name;
	pageParam.cardId = elderView.data.cardId;
	/*
	pageParam.elder = elderView.data;
	pageParam.elderFamilyMember = elderFamilyMemberView.data;
	pageParam.elderMemContacts = elderMemContactsView.data;
	*/
	
	var url = '5-1-2ywrent-1.html?pageParam=' + encodeURIComponent(JSON.stringify(pageParam));
	window.open(url);
}
